<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<!-- Copyright 1997 The Open Group, All Rights Reserved -->
<title>getitimer</title>
</head><body bgcolor=white>
<center>
<font size=2>
The Single UNIX &reg; Specification, Version 2<br>
Copyright &copy; 1997 The Open Group

</font></center><hr size=2 noshade>
<h4><a name = "tag_000_005_590">&nbsp;</a>NAME</h4><blockquote>
getitimer, setitimer - get or set value of interval timer
</blockquote><h4><a name = "tag_000_005_591">&nbsp;</a>SYNOPSIS</h4><blockquote>
<pre><code>

#include &lt;<a href="systime.h.html">sys/time.h</a>&gt;

int getitimer(int <i>which</i>, struct itimerval *<i>value</i>);
int setitimer(int <i>which</i>, const struct itimerval *<i>value</i>,
    struct itimerval *<i>ovalue</i>);
</code>
</pre>
</blockquote><h4><a name = "tag_000_005_592">&nbsp;</a>DESCRIPTION</h4><blockquote>
The
<i>getitimer()</i>
function stores the current value of the timer specified by <i>which</i> into
the structure pointed to by <i>value</i>.  The
<i><a href="setitimer.html">setitimer()</a></i>
function sets the timer specified by <i>which</i> to the value
specified in the structure pointed to by <i>value</i>, and if <i>ovalue</i> is
not a null pointer, stores the previous value of the timer in the structure
pointed to by <i>ovalue</i>.
<p>
A timer value is defined by the <b>itimerval</b> structure.
If <i>it_value</i>
is non-zero, it indicates the time to the next timer expiration.  If
<i>it_interval</i> is non-zero, it specifies a value to be used in
reloading <i>it_value</i> when the timer expires.  Setting <i>it_value</i>
to 0 disables a timer, regardless of the value of <i>it_interval</i>.
Setting <i>it_interval</i> to 0 disables a timer after its
next expiration (assuming <i>it_value</i> is non-zero).
<p>
Implementations may place limitations on the granularity of timer values.
For each interval timer, if the requested timer value requires a finer
granularity than the implementation supports, the actual timer value will be
rounded up to the next supported value.
<p>
An XSI-conforming implementation provides each process with at least three
interval timers, which are indicated by the <i>which</i> argument:
<dl compact>

<dt>ITIMER_REAL<dd>

Decrements in real time.
A SIGALRM signal is delivered when this timer
expires.

<dt>ITIMER_VIRTUAL<dd>

Decrements in process virtual time.  It runs only when the process is
executing.  A SIGVTALRM signal is delivered when it expires.

<dt>ITIMER_PROF<dd>

Decrements both in process virtual time and
when the system is running on behalf of the process.
It is designed to be used by interpreters in statistically
profiling the execution of interpreted programs.
Each time the ITIMER_PROF timer expires, the SIGPROF signal is delivered.

</dl>
<p>
The interaction between
<i><a href="setitimer.html">setitimer()</a></i>
and any of
<i><a href="alarm.html">alarm()</a></i>,
<i><a href="sleep.html">sleep()</a></i>
or
<i><a href="usleep.html">usleep()</a></i>
is unspecified.
</blockquote><h4><a name = "tag_000_005_593">&nbsp;</a>RETURN VALUE</h4><blockquote>
Upon successful completion,
<i>getitimer()</i>
or
<i><a href="setitimer.html">setitimer()</a></i>
returns 0.
Otherwise, -1 is returned and <i>errno</i> is set to indicate the error.
</blockquote><h4><a name = "tag_000_005_594">&nbsp;</a>ERRORS</h4><blockquote>
The
<i><a href="setitimer.html">setitimer()</a></i>
function will fail if:
<dl compact>

<dt>[EINVAL]<dd>
The <i>value</i> argument is not in canonical form.  (In canonical form, the
number of microseconds is a non-negative integer less than 1,000,000 and the
number of seconds is a non-negative integer.)

</dl>
<p>
The
<i>getitimer()</i>
and
<i><a href="setitimer.html">setitimer()</a></i>
functions may fail if:
<dl compact>

<dt>[EINVAL]<dd>
The <i>which</i> argument is not recognised.

</dl>
</blockquote><h4><a name = "tag_000_005_595">&nbsp;</a>EXAMPLES</h4><blockquote>
None.
</blockquote><h4><a name = "tag_000_005_596">&nbsp;</a>APPLICATION USAGE</h4><blockquote>
None.
</blockquote><h4><a name = "tag_000_005_597">&nbsp;</a>FUTURE DIRECTIONS</h4><blockquote>
None.
</blockquote><h4><a name = "tag_000_005_598">&nbsp;</a>SEE ALSO</h4><blockquote>
<i><a href="alarm.html">alarm()</a></i>,
<i><a href="sleep.html">sleep()</a></i>,
<i><a href="timer_gettime.html">timer_gettime()</a></i>,
<i><a href="timer_settime.html">timer_settime()</a></i>,
<i><a href="ualarm.html">ualarm()</a></i>,
<i><a href="usleep.html">usleep()</a></i>,
<i><a href="signal.h.html">&lt;signal.h&gt;</a></i>,
<i><a href="systime.h.html">&lt;sys/time.h&gt;</a></i>.
</blockquote><hr size=2 noshade>
<center><font size=2>
UNIX &reg; is a registered Trademark of The Open Group.<br>
Copyright &copy; 1997 The Open Group
<br> [ <a href="../index.html">Main Index</a> | <a href="../xshix.html">XSH</a> | <a href="../xcuix.html">XCU</a> | <a href="../xbdix.html">XBD</a> | <a href="../cursesix.html">XCURSES</a> | <a href="../xnsix.html">XNS</a> ]

</font></center><hr size=2 noshade>
</body></html>
